#include <stdio.h>
#define MAXLINE 1000 /* maximum input line length */
int mgetline(char line[], int max);
int strindex(char source[], char searchfor[]);
char pattern[] = "ould"; /* pattern to search for */
/* find all lines matching pattern */
int main()
{
    int index;
    char line[MAXLINE];
    while (mgetline(line, MAXLINE) > 0) {
        index = strindex(line, pattern);
        printf("%s========%d\n", line, index);
    }
}

/* getline: get line into s, return length */
int mgetline(char s[], int lim)
{
    int c, i;
    i = 0;
    while (--lim > 0 && (c=getchar()) != EOF && c != '\n')
        s[i++] = c;
    if (c == '\n')
        s[i++] = c;
    s[i] = '\0';
    return i;
}

/* strindex: return index of t in s, -1 if none */
int strindex(char s[], char t[])
{
    int i, j, k;
    for (i = strlen(s) - 1; i >= 0 ; i--) {
        for (j = i, k = strlen(t)-1; k >= 0 && s[j] == t[k]; j--, k--)
            ;
        if (k == -1)
            return j+1;
    }
    return -1;
}